//
//  SenderButton.swift
//  LiuWeiBo
//
//  Created by 刘晓晨 on 2017/4/3.
//  Copyright © 2017年 刘晓晨. All rights reserved.
//

import UIKit

class SenderButton: UIButton {

    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    fileprivate func setupUI() {
        
        imageView?.contentMode = .center
        titleLabel?.textAlignment = .center
        
    }
    
    override func layoutSubviews() {
        super.layoutSubviews()
        //设置自带图片的位置
        imageView?.frame.origin.y = 0
        imageView?.frame.origin.x = 0
        
        //设置自带图片的大小
        imageView?.frame.size.width = bounds.size.width
        imageView?.frame.size.height = bounds.size.width
        
        //设置label的位置
        titleLabel?.frame.origin.y = bounds.size.width
        titleLabel?.frame.origin.x = 0
        
        //设置label的大小
        titleLabel?.frame.size.width = bounds.size.width
        titleLabel?.frame.size.height = bounds.size.height - bounds.size.width
    }

}
